<%@ page language="java" import="java.util.*,com.hs.auth.model.*,com.hs.wdss.model.*,com.hs.auth.*" pageEncoding="utf-8"%>
<%
	WdssDisinfo obj = (WdssDisinfo)request.getAttribute("obj");
 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="../../include.jsp"%>  
<script src="<%=basePath %>app/javascripts/transform.js"></script>
<script src='<%=basePath%>dwr/interface/dataProhelper.js'></script>  
<script language="javascript" type="text/javascript">
function savedata()
{
	var wdssid = window.parent.datapromenu.document.all.wdssid.value;
	if(wdssid == ""){
		alert("请先保存医案信息！");	
		return;
	}else {
		var paraname = document.getElementById("paraname").value; 
		var memo = document.getElementById("memo").value; 
		if(isNull(paraname)){
			alert("请输入并发症名称！");
			return; 
   		} 
	   	dataProhelper.addParaDis(paraname,memo,wdssid,callback4addPara);
	}
	
}
function callback4addPara(message){ 
      var cellFunctions = [    
          function(item) {   
           	return item.paraname;
          },
          function(item) {  
           	return item.memo;
          },
          function(item) {  
           	return "<a href=javaScript:onclick=delPara('"+item.id+"');>删 除</a>";
          }
      ];    
     var index = message.indexOf("$");  
     var paraid = message.substring(0,index); 
     var rowdata = message.substring(index+1); 
     var data = eval('('+rowdata+')');   
      DWRUtil.addRows("paralist", data, cellFunctions,{
          rowCreator:function(options) { //自定义 tr 的创建行为 
          var trobj = document.createElement("tr");   
          trobj.setAttribute("id","para_"+paraid);  
          return trobj; 
     },cellCreator:function(options) {
	 var cell = document.createElement("td"); 
	 return cell;
	}, escapeHtml:false
	     });
	document.getElementById("paraname").value=''; 
	document.getElementById("memo").value=''; 
	//刷新左边菜单
	var wdssid = window.parent.datapromenu.document.all.wdssid.value;
	window.parent.datapromenu.frameElement.src = "<%=basePath%>produce/datapromenu.do?wdssid="+wdssid;
	alert('并发症信息保存成功！'); 
}

function delPara(id){
	if(confirm("确认要删除该并发症信息吗？")){
	        dataProhelper.delParaDis(id,callback4delPara);
    }
} 
function callback4delPara(data){   
	var tbody  = document.getElementById("paralist");// tbody 的id 
    var rowobj = document.getElementById("para_"+data);  
    tbody.removeChild(rowobj);
    //刷新左边菜单
	var wdssid = window.parent.datapromenu.document.all.wdssid.value;
	window.parent.datapromenu.frameElement.src = "<%=basePath%>produce/datapromenu.do?wdssid="+wdssid;
}
function backlist()
{
	window.parent.window.location.href = "<%=basePath%>produce/dataprolist.do"
}
</script>
</head>
<body>
<div class="current">当前位置：数据加工 &gt; 并发症信息</div>
        <table border="0" cellspacing="0" cellpadding="0" class="news"> 
        <caption>
          并发症信息
          </caption>
          <tr>
            <th width="15%">并发症名称</th>
            <td width="35%"><input type="text" name="paraname" id="paraname" value="" style="width:99%"/>
            <input name="disid" type="hidden" value=""/>
            <input name="paraid" type="hidden" value=""/></td>
           
            <th width="15%">备注</th>
            <td width="35%"><input type="text" name="memo" id="memo" value="" style="width:99%"/>
            </td> 
          </tr>
          <tr> 
           <td colspan=4 align=center>
           		<input  type="button" value=" 保 存 " onclick="savedata();" class="butt"/>
           		<input  type="button" value=" 返 回 " onclick="backlist();" class="butt"/>
           </td>
          </tr>
        </table> 
        <table border="0" cellspacing="0" cellpadding="0" style="width:100%" class="list">
          <caption>并发症信息列表</caption>  
          <tr>  
            <th width="10%">并发症名称</th>
            <th width="25%">备注</th> 
            <th width="10%">删除</th> 
          </tr>
          <tbody id=paralist>
           <%if(obj != null && !obj.getParaset().isEmpty()){
                Set paraset = obj.getParaset();
                Iterator iter = paraset.iterator();
          		while(iter.hasNext()){
          			WdssParainfo parainfo = (WdssParainfo)iter.next();
           %>
	           <tr id=para_<%=parainfo.getId() %>>
 	           <td style="word-break:break-all;over-flow:hidden;"><%=parainfo.getParaname()%></td>
 	           <td style="word-break:break-all;over-flow:hidden;"><%=StringUtilTool.NULL2Blank(parainfo.getMemo())%></td>
 	           <td><a href="javaScript:onclick=delPara('<%=parainfo.getId() %>')">删除</a></td>
	           </tr>
           <%}} %>
           </tbody>
        </table>
</body>
</html>


